<ui:composition template="../../template/principal_00.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui" >

    <ui:define name="titulo">
        #{pd_DepartamentoBean.titulo}
    </ui:define>

    <ui:define name="panelPrincipal">

        <h:form id="formulario" prependId="false">

            <p:panel header="#{pd_DepartamentoBean.titulo}" style="width:100%;" styleClass="panel">

                <p:menubar style="width: 100%" >

                    <p:menuitem value=" #{msgs.nuevo}" icon="blank16" id="btnNew"
                               action="#{pd_DepartamentoBean.nuevo}"
                               process="@this"
                               update="@form"  />

                    <p:menuitem value=" #{msgs.pcc_guardar}" icon="save16"
                                action="#{pd_DepartamentoBean.guardar(false)}"
                                update="@form" />

                    <p:menuitem value=" #{msgs.guardar_nuevo}" icon="saveNew16"
                                action="#{pd_DepartamentoBean.guardar(true)}"
                                oncomplete="btnNew.click()"
                                update="@form" />

                </p:menubar>

                <p:messages showDetail="true" />
                
                <h:panelGrid columns="2" rendered="#{not empty pd_DepartamentoBean.departamento}"
                             columnClasses="colLabel,colDato" >

                    <h:outputText value="Código"/>
                    <p:inputText value="#{pd_DepartamentoBean.departamento.codigo}" size="6" readonly="#{not empty pd_DepartamentoBean.departamento.codigo}" />

                    <h:outputText value="Descripción"/>
                    <p:inputText value="#{pd_DepartamentoBean.departamento.descrp}" size="40" />

                    <h:outputText value="Activo"/>
                    <p:selectOneRadio  value="#{pd_DepartamentoBean.departamento.auditoria.debaja}" >
                        <f:selectItem itemLabel="Si" itemValue="N" />
                        <f:selectItem itemLabel="No" itemValue="S" />
                    </p:selectOneRadio>
                    
                </h:panelGrid>

                <p:spacer height="10" />

                <p:dataTable id="lista" value="#{pd_DepartamentoBean.lista}"  
                             var="d" style="width: 400px;">

                    <f:facet name="header" >
                        Departamentos
                    </f:facet>

                    <p:column headerText="Código" width="50">
                        <h:outputText value="#{d.codigo}"/>
                    </p:column>

                    <p:column headerText="Descripción" width="270">
                        <h:outputText value="#{d.descrp}"/>
                    </p:column>

                    <p:column headerText="Activo" width="30">

                        <h:outputText value="Si" rendered="#{d.auditoria.debaja == 'N'}" />
                        <h:outputText value="No" rendered="#{d.auditoria.debaja == 'S'}" />

                    </p:column>
                    
                    <p:column headerText="" width="50">

                        <p:commandButton icon="find16" id="seleMovim"
                                         actionListener="#{pd_DepartamentoBean.seleccionar(d)}"
                                         update="@form" process="@this" styleClass="btnTabla" />

                         <p:commandButton icon="delete16" id="deleteMovim"
                                         actionListener="#{pd_DepartamentoBean.eliminar(d)}"
                                         update="@form" process="@this" styleClass="btnTabla" />

                    </p:column>
                    
                </p:dataTable>

            </p:panel>            

        </h:form>

    </ui:define>

</ui:composition>